{/* Copyright 2025 Adobe. All rights reserved.
This file is licensed to you under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License. You may obtain a copy
of the License at http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software distributed under
the License is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR REPRESENTATIONS
OF ANY KIND, either express or implied. See the License for the specific language
governing permissions and limitations under the License. */}

import {Layout} from '../../src/Layout';
export default Layout;
import {GroupedPropTable} from '../../src/PropTable';
import {InterfaceType} from '../../src/types';
import {FunctionAPI} from '../../src/FunctionAPI';
import docs from 'docs:@react-aria/interactions';
export const section = 'Interactions';
export const description = 'Determines whether keyboard focus should be visible based on interaction mode.';

# useFocusVisible

<PageDescription>{docs.exports.useFocusVisible.description}</PageDescription>

```tsx render
"use client";
import {useFocusVisible} from 'react-aria';

function Example() {
  let {isFocusVisible} = useFocusVisible({isTextInput: true});

  return (
    <>
      <div>Focus visible: {String(isFocusVisible)}</div>
      <label style={{display: 'block'}}>
        First Name: <input />
      </label>
      <label style={{display: 'block'}}>
        Last Name: <input />
      </label>
    </>
  );
}
```

## Features

`useFocusVisible` handles focus interactions for the page and determines whether keyboard focus
should be visible (e.g. with a focus ring). Focus visibility is computed based on the current
interaction mode of the user. When the user interacts via a mouse or touch, then focus is not
visible. When the user interacts via a keyboard or screen reader, then focus is visible. This is similar to
the [:focus-visible](https://developer.mozilla.org/en-US/docs/Web/CSS/:focus-visible) pseudo class
in CSS.

To determine whether a focus ring should be visible for an individual component rather than
globally, see [useFocusRing](useFocusRing).

## API

<FunctionAPI function={docs.exports.useFocusVisible} links={docs.links} />

### FocusVisibleProps

<InterfaceType {...docs.exports.FocusVisibleProps} />

### FocusVisibleResult

<InterfaceType {...docs.exports.FocusVisibleResult} />
